/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-02-23
 * Time: 18:12
 */
public class test3 {
    /**
     * LeetCode LCR 016 无重复字符的最长字串
     */

    public int lengthOfLongestSubstring(String ss) {
        char[] s = ss.toCharArray();
        int right = 0;
        int left = 0;
        int ret = 0;
        int n = s.length;
        int[] hash = new int[128];
        while(right<n){
            hash[s[right]]++;
            while(hash[s[right]]>1){
                hash[s[left]]--;
                left++;
            }
            ret = Math.max(ret,right-left+1);
            right++;
        }
        return ret;
    }
}
